import time
from concurrent.futures import ThreadPoolExecutor, wait


def run(i):
    print(f'线程{i}')
    time.sleep(1)


if __name__ == '__main__':
    t_list = [1, 2, 3, 4, 5]
    pool = ThreadPoolExecutor(3)
    # 方法一，不等待
    # for i in t_list:
    #     pool.submit(run, i)

    # 简写
    # wait：等待线程池全部完成
    # task_list = [pool.submit(run, i) for i in t_list]
    # wait(task_list)

    # map----小疑问，线程池3个连接满后，主线程的over先执行了
    pool.map(run, t_list)
    print('over')
